<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <h3>VUE.js</h3>
        <!-- 文本赋值 -->
        <h3>双花括号{{msg}}</h3>

        <span v-once>v-once 这个将不会改变：{{msg}} <i> {{time}} </i></span>

        <p>{{rawHtml}}</p>
        <p v-html="rawHtml"></p>

        <p v-bind:title="msg">xss
            <span v-html="xss"></span>
        </p>
        <!-- xss  csrf攻击 -->

        <input type="text" disabled="xxx">
        <input type="checkbox" :checked="checked">

        <!-- javascript 表达式 if else while switch xx?yy:zz -->
        <hr>
        <p>{{msg+1}}</p>
        <p>{{ok ? 'YES' : 'NO'}}</p>
        <p>{{msg.split('').reverse().join('')}}</p>

        <div v-bind:id="'list-' + id"></div>
        <!-- id是参数 -->
        <p>{{Math.random()}}</p>

        <p v-if="ok">现在你看到我了</p>

        <!-- <img src="" alt="msg">
         v-bind:[attr]相当于alt
        -->
        <img src="" v-bind:[attr]="msg">
        <hr>
        <!-- 修饰符 .prevent-->
        <a href="http://www.baidu.com" @click.prevent="clickHandler">百度</a>
    </div>
    <script>
        new Vue({
            el: "#app",
            data: {
                msg: "hello vue",
                time: null,
                rawHtml: `<span style="color:red">xxxx</spam>`,
                xss: ` <span onclick='alert("123")')>xxx</span>`,
                checked: "",
                ok: true,
                id: "xxyy",
                attr: "alt",
            },
            methods: {
                clickHandler: function () {
                    // e.preventDefault()
                    console.log('123');
                }
            },
        })
    </script>
    <!-- 
        {{任意js表达式}} v-test v-html xss csrf
        v-once
        v-bind:[attr]
        v-on:click=@click
        
          完整语法
        <a v-bind:href="url">...</a>

            缩写 
        <a :href="url">...</a> 

        动态参数的缩写 (2.6.0+) 
        <a :[key]="url"> ... </a>  
     -->
</body>

</html>